﻿namespace YnabCsvConverter.Core.Tests
{
   using Converters;
   using Converters.Betterment;
   using NUnit.Framework;

   /// <summary>
   /// Unit Test for the "Betterment" converter
   /// </summary>
   [TestFixture]
   public class BettermentTests
   {
      /// <summary>
      /// The subject under test.
      /// </summary>
      private BettermentConverter _sut;

      /// <summary>
      /// Initializes a new instance of the <see cref="EasybankTests" /> class.
      /// </summary>
      public BettermentTests()
      { 
      }

      /// <summary>
      /// Tests the setup.
      /// </summary>
      [TestFixtureSetUp]
      public void TestSetup()
      {
         _sut = new BettermentConverter();
      }

      /// <summary>
      /// Test if a Betterment record is converted to a ynab record.
      /// </summary>
      [Test]
      public void ConvertRecordWithInflow_BettermentRecord_ToYnabRecord()
      {
         // Given
         var bettermentRecord = new BettermentRecord
         {
            AccountName = "College",
            Description = "Market Change",
            Amount = "$2.00 ",
            DateTime = "1/20/2012 13:11",
         };

         // When
         var ynabRecord = _sut.ConvertRecord(bettermentRecord);

         // Then
         var expectedYnabRecord = new YnabRecord
         {
            Date = "01/20/2012",
            Payee = "College",
            Category = "Market Change",
            Memo = "Market Change",
            Outflow = "",
            Inflow = "2.00",
         };

         Assert.That(ynabRecord, Is.EqualTo(expectedYnabRecord));
      }

      /// <summary>
      /// Test if a Betterment record is converted to a ynab record.
      /// </summary>
      [Test]
      public void ConvertRecordWithOutflow_BettermentRecord_ToYnabRecord()
      {
         // Given
         var bettermentRecord = new BettermentRecord
         {
            AccountName = "College",
            Description = "Market Change",
            Amount = "($1.00) ",
            DateTime = "1/20/2012 13:11",
         };

         // When
         var ynabRecord = _sut.ConvertRecord(bettermentRecord);

         // Then
         var expectedYnabRecord = new YnabRecord
         {
            Date = "01/20/2012",
            Payee = "College",
            Category = "Market Change",
            Memo = "Market Change",
            Outflow = "1.00",
            Inflow = "",
         };

         Assert.That(ynabRecord, Is.EqualTo(expectedYnabRecord));
      }
   }
}
